from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    # 数据库配置
    DATABASE_URL: str = "mysql+pymysql://root:123456@192.168.5.86:3306/thrushdb?charset=utf8mb4"
    
    # JWT配置
    SECRET_KEY: str = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    
    # Redis配置
    REDIS_URL: str = "redis://localhost:6379"
    
    # 对象存储配置 (MinIO)
    STORAGE_PROVIDER: str = "minio"
    MINIO_ENDPOINT: str = "localhost:9000"
    MINIO_ACCESS_KEY: str = "minioadmin"
    MINIO_SECRET_KEY: str = "minioadmin"
    MINIO_BUCKET_NAME: str = "thrush-ai"
    MINIO_SECURE: bool = False
    
    # 微信支付配置
    WECHAT_PAY_APP_ID: str = ""
    WECHAT_PAY_MCH_ID: str = ""
    WECHAT_PAY_API_KEY: str = ""
    WECHAT_PAY_NOTIFY_URL: str = ""
    WECHAT_PAY_CERT_PATH: str = ""
    WECHAT_PAY_KEY_PATH: str = ""
    
    # 支付宝配置
    ALIPAY_APP_ID: str = ""
    ALIPAY_PRIVATE_KEY: str = ""
    ALIPAY_PUBLIC_KEY: str = ""
    ALIPAY_NOTIFY_URL: str = ""
    ALIPAY_RETURN_URL: str = ""
    ALIPAY_GATEWAY_URL: str = "https://openapi.alipay.com/gateway.do"
    
    # 文件上传配置
    MAX_FILE_SIZE: int = 50 * 1024 * 1024  # 50MB
    ALLOWED_IMAGE_TYPES: list = ["image/jpeg", "image/png", "image/webp"]
    ALLOWED_VIDEO_TYPES: list = ["video/mp4", "video/avi", "video/mov"]
    
    # AI 服务配置
    AI_DEFAULT_PROVIDER: str = "mock"
    AI_SERVICES_ENABLED: bool = True
    AI_REQUEST_TIMEOUT: int = 300
    AI_MAX_CONCURRENT_REQUESTS: int = 10
    
    # Mock服务通用配置
    MOCK_DELAY_MIN: float = 1.0
    MOCK_DELAY_MAX: float = 5.0
    MOCK_FAILURE_RATE: float = 0.05
    
    # OpenAI DALL-E 配置
    OPENAI_API_KEY: str = ""
    OPENAI_BASE_URL: str = "https://api.openai.com/v1"
    OPENAI_MODEL: str = "dall-e-3"
    OPENAI_USE_MOCK: bool = True
    OPENAI_ENABLED: bool = True
    
    # Stability AI 配置
    STABILITY_AI_API_KEY: str = ""
    STABILITY_AI_BASE_URL: str = "https://api.stability.ai/v1"
    STABILITY_AI_ENGINE: str = "stable-diffusion-xl-1024-v1-0"
    STABILITY_AI_USE_MOCK: bool = True
    STABILITY_AI_ENABLED: bool = True
    
    # Google Veo 3 配置
    GOOGLE_VEO3_API_KEY: str = ""
    GOOGLE_VEO3_PROJECT_ID: str = ""
    GOOGLE_VEO3_LOCATION: str = "us-central1"
    GOOGLE_VEO3_SERVICE_ACCOUNT_PATH: str = ""
    GOOGLE_VEO3_MAX_DURATION: int = 60
    GOOGLE_VEO3_USE_MOCK: bool = True
    GOOGLE_VEO3_ENABLED: bool = True
    
    # Runway ML 配置
    RUNWAY_ML_API_KEY: str = ""
    RUNWAY_ML_MODEL_NAME: str = "gen3a_turbo"
    RUNWAY_ML_MAX_DURATION: int = 10
    RUNWAY_ML_USE_MOCK: bool = True
    RUNWAY_ML_ENABLED: bool = True
    
    # 即梦AI 配置
    JIMENG_AI_API_KEY: str = ""
    JIMENG_AI_USER_ID: str = ""
    JIMENG_AI_MODEL_NAME: str = "jimeng-1.0"
    JIMENG_AI_MAX_DURATION: int = 6
    JIMENG_AI_USE_MOCK: bool = False
    JIMENG_AI_ENABLED: bool = True

    class Config:
        env_file = ".env"

settings = Settings()
